<?php

class ProfileAction extends Action  {
		
	public function main(){
		if ($this->_request['action']=='modify') {
			$this->__update();
		}else{
			$this->__load();
			$this->_response['do']  = $this->_request['do'];
		}
	
	}


	private function __update(){
		$obj = new UserInfoDAO();
		$res = $obj->updatePassword($this->_request['UserID'],$this->_request['password1']);
		
		if($res){
			$ret = $obj->getUserById($this->_request['UserID']);
			$login = new Login();
			$login->dologin($ret['UserName'],  $ret['Password']);
		}
		header("Location:index.php?do=index/user_list");
		die();
	}



	private function __load(){
		if ($this->_request['UserID']){
			$this->_response['UserID'] = $this->_request['UserID'];
		}else{
			$login = new Login();
			$ret = $login->loginByCookie();
			$this->_response['UserID'] = $ret['UserID'];
		}
	}




	
	
}
?>